package com.ujiuye.utils;

import javax.servlet.http.Part;
import java.io.File;
import java.util.UUID;

public class FileUploadUtils {
    public static  String uploaPic(Part part)throws Exception{
        //获取上传图片名
        String pic =part.getSubmittedFileName();
        //确定上传到服务器下的路径
        String path="D:\\dow";
        File file = new File(path);
        if (!file.exists()){
            //判断上传路径是否存在，不纯在则创建
            file.mkdir();
        }
        //上传操作：E\stupic\1.jpg
        pic = UUID.randomUUID()+pic;
        part.write(path+"/"+pic);
        return pic;
    }
}
